package com.casic.license.view;


import com.ddxz.tool.core.convert.DateUtil;
import com.ddxz.tool.core.convert.StringUtil;
import com.ddxz.tool.core.security.SecurityUtil;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/7/23
 */

public class ParseListener implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
        JTextArea license = (JTextArea) window.getAllComponent().get("license");
        JTextArea show = (JTextArea) window.getAllComponent().get("show");
        List<String> parts = StringUtil.getList(SecurityUtil.rsaDecode(license.getText()), "\\.");
        long time = StringUtil.toLong(parts.get(2));
        show.setText(parts.get(0) + "." + parts.get(1) + "." + DateUtil.toCvtDateTime(time));
    }

    private LicenseWindow window;

    public ParseListener(LicenseWindow window) {
        this.window = window;
    }
}
